package cn.com.headfree.mouldshow.dao.impl;

import cn.com.headfree.entity.TPartRank;
import cn.com.headfree.mouldshow.dao.TPartRankDao;
import cn.com.headfree.vo.simple.PartRankVo;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import com.gta.edu.sdk.util.StringUtil;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("/tPartRankDao")
public class TPartRankDaoImpl extends BaseDaoImpl<TPartRank> implements TPartRankDao {

    /**
     * 根据部门id查询所有的人员
     * @param baseorgId
     * @return
     */
    @Override
    public List<PartRankVo> findByBaseorgId(String baseorgId) {
        return null;
    }

    @Override
    public  List<TPartRank> getTPartRankByMids(List<String> mainIds, String type){
        if(mainIds.isEmpty()|| StringUtil.isNullOrEmpty(type)){
            return null;
        }
        String idsStr="";
        for(int i=0;i<mainIds.size();i++){
            idsStr+=",'"+mainIds.get(i)+"'";
        }

        idsStr=idsStr.substring(1);

        String jsCode="";

//		String sql = " select t.id,t.erp_no,p.user_name,t.id_card_no,t.item_id,t.item_type,t.rank,t.role,t.del_sign,t.is_valid, " +
//				" t.audit_state,t.orignal_id,t.flow_status,t.business_type_id,t.isc_user_id , " +
//				" GET_DIC('"+ jsCode +"',t.role) as role_name from t_part_rank t left join isc_user i on t.erp_no=i.fax " ;

        String sql = "select t.id,t.erp_no,t.user_name,t.id_card_no,t.item_id,t.item_type,t.rank,t.role,t.del_sign,t.is_valid,t.audit_state,t.orignal_id,t.flow_status,t.business_type_id,t.isc_user_id from t_part_rank t " ;
        StringBuilder sqlBuilder = new StringBuilder(sql);
        sqlBuilder.append(" where item_id in (").append(idsStr).append(") and item_type='").append(type).append("' order by item_type, rank ");
        return this.findAllBySQL(TPartRank.class, sqlBuilder.toString(), null, false,null);

    }

}
